# ----------------------------------------------------------------------------
# 交叉编译目标平台
# ----------------------------------------------------------------------------

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)



# ----------------------------------------------------------------------------
# gnu-arm 工具链通用设置导入
# ----------------------------------------------------------------------------

include("${CMAKE_CURRENT_LIST_DIR}/internal/gnu-arm_common.cmake")



# ----------------------------------------------------------------------------
# gnu-arm 工具链平台架构相关选项设置
# ----------------------------------------------------------------------------

set(MCU_FLAGS "")
list(APPEND MCU_FLAGS
    "-mthumb"
    "-mcpu=cortex-m4"
    "-mfloat-abi=hard"
    "-mfpu=fpv4-sp-d16"
)
string(REPLACE ";" " " MCU_FLAGS "${MCU_FLAGS}")

set(CMAKE_C_FLAGS    "${MCU_FLAGS} ${CMAKE_C_FLAGS}"   CACHE STRING "C Compiler options"   FORCE)
set(CMAKE_CXX_FLAGS  "${MCU_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING "C++ Compiler options" FORCE)
set(CMAKE_ASM_FLAGS  "${MCU_FLAGS} ${CMAKE_ASM_FLAGS}" CACHE STRING "ASM Compiler options" FORCE)



# ----------------------------------------------------------------------------
# gnu-arm 工具链相关配置信息打印
# ----------------------------------------------------------------------------

# message(STATUS "---------------------------------------- START ----------------------------------------")
# message(STATUS "| CMAKE_FIND_ROOT_PATH | " ${CMAKE_FIND_ROOT_PATH})
# message(STATUS "---------------------------------------------------------------------------------------")
# message(STATUS "| C Compiler           | " ${CMAKE_C_COMPILER})
# message(STATUS "| C++ Compiler         | " ${CMAKE_CXX_COMPILER})
# message(STATUS "| ASM Compiler         | " ${CMAKE_ASM_COMPILER})
# message(STATUS "| OBJCOPY              | " ${CMAKE_OBJCOPY})
# message(STATUS "| SIZE                 | " ${CMAKE_SIZE})
# message(STATUS "---------------------------------------------------------------------------------------")
# message(STATUS "| C Compiler   options | " ${CMAKE_C_FLAGS})
# message(STATUS "| C++ Compiler options | " ${CMAKE_CXX_FLAGS})
# message(STATUS "| ASM Compiler options | " ${CMAKE_ASM_FLAGS})
# message(STATUS "| Linker       options | " ${CMAKE_EXE_LINKER_FLAGS})
# message(STATUS "----------------------------------------  END  ----------------------------------------")
